#!/bin/bash

tmux has-session -t nvimspace
if [ $? != 0 ]; then
    tmux new-session -s nvimspace -n editor -d
    tmux send-keys -t nvimspace 'nvim --listen /tmp/.nvim.pipe' C-m
    tmux new-window -n ranger -t nvimspace 'ranger --confdir ~/.nvim_ranger/ ~ /etc'
    #tmux new-window -n taskbook -t nvimspace -c '/home/luyanfei/myorg/'
    #tmux send-keys -t nvimspace 'emacs -t && emacsclient -t asap.org' C-m
    tmux select-window -t nvimspace:2
fi

if [ -z "$TMUX" ]; then
    tmux -u attach-session -t nvimspace
else
    tmux -u switch-client -t nvimspace
fi
